﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace BussinessLib
{
    [Serializable]
    public class CustomIdentity:IIdentity
    {

        #region IIdentity Members

        public string AuthenticationType
        {
            get { return _AuthenticationType; }
        }

        public bool IsAuthenticated
        {
            get { return _isAuthenticated; }
        }

        public string Name
        {
            get { return _name; }
        }

        #endregion

        private string _name = "";
        private string _AuthenticationType = "";
        private bool _isAuthenticated = false;

        private WindowsIdentity _windowsIdentity = null;

        public WindowsIdentity windowsIdentity
        {
            get { return _windowsIdentity; }
           
        }


        private bool _isWindows = false;

        public bool isWindows
        {
            get { return _isWindows; }
            
        }


        public void setWindows(WindowsIdentity identity)
        {
            _windowsIdentity = identity;
            _name = _windowsIdentity.Name;
            _AuthenticationType = _windowsIdentity.AuthenticationType;
            _isAuthenticated = _windowsIdentity.IsAuthenticated;
            _isWindows = true;

        }


        public void setName(string __name)
        {
            _name = __name;
            _windowsIdentity = null;
            _isWindows = false;
        }

        public void setAuthenticationType(string __AuthenticationType)
        {
            _AuthenticationType = __AuthenticationType;
            _windowsIdentity = null;
            _isWindows = false;

        }

        public void authenticate ()
        {
            _isAuthenticated = true;
            _windowsIdentity = null;
            _isWindows = false;
        }





    }
}
